#pragma once
#include "d3dutil.h"
#include "LevelElement.h"
#include "Vertex.h"
#include "PhysX.h"
#include <vector>

//Forward declaration
class PosNormShader;
class Level;
using namespace std;

class SkyBox : public LevelElement
{
public:
	SkyBox(Level* level, const tstring& fileName);
	virtual ~SkyBox(void);
	virtual void Initialize(ContentManager *pContentManager);
	virtual void Tick(const InputState & refInputState){}
	virtual void Draw(const RenderContext* pRenderContext);
	virtual void DrawRefraction(const RenderContext* pRenderContext, D3DXPLANE refractionplane){}
	virtual void DrawReflection(const RenderContext* pRenderContext, D3DXMATRIX reflectionviewmatrix, D3DXPLANE reflectionplane);
	virtual void DrawShadowMap(const RenderContext* pRenderContext){}

	void Visible(bool visible) {m_bVisible = visible;}
	private:
	void CreateEffect(ContentManager *pContentManager);
	void GetEffectVariables(ID3D10Effect* pEffect);
	void DefineInputlayout();
	void BuildShape();
	void AddTriangle (unsigned int a, unsigned int b, unsigned c);
	void BuildVertexBuffer();
	void BuildIndexBuffer();
	//-------------------------------------------------
	// Datamembers
	//-------------------------------------------------
	bool m_bVisible;
	bool m_bReflection;
	D3DXMATRIX m_ReflectionViewMatrix;

	ID3D10InputLayout* m_pVertexLayout;
	ID3D10Buffer* m_pVertexBuffer;
	ID3D10Buffer* m_pIndexBuffer;
	ID3D10Effect* m_pDefaultEffect;
	ID3D10EffectTechnique* m_pDefaultTechnique;
	ID3D10ShaderResourceView* m_pCubeMap;
	ID3D10EffectShaderResourceVariable* m_pCubeMapVariable;
	ID3D10EffectMatrixVariable* m_pWorldViewProjectionVariable;
	tstring m_TexFileName;
	vector<VertexPos> m_VecVertices;
	vector<DWORD> m_VecIndices;

	SkyBox(const SkyBox& t);
	SkyBox& operator=(const SkyBox& t);
};